import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class PersionPage extends StatefulWidget {

  @override
  _PersionPageState createState() => _PersionPageState();
}

final List list = [
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201911/zzpic21391.jpg",
    "text":"夏天总想你。夏天不听话"
  },
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201909/zzpic19849.jpg",
    "text":"我能作茧自缚，就能破茧成蝶 "
  },
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201908/zzpic19579.jpg",
    "text":"捂上嘴，忍住不说话"
  },
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201907/zzpic19069.jpg",
    "text":"也许，你不过是错的人出现在对的时间"
  },
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201906/zzpic18777.jpg",
    "text":"就怪当初双手即使拥有竟蠢到会当作永久"
  },
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201912/zzpic21576.jpg",
    "text":"某人铭记，我们的感情路线已走到尽头"
  },
  {
    "url":"http://pics.sc.chinaz.com/files/pic/pic9/201904/zzpic17719.jpg",
    "text":"有的人说不清哪里好但就是谁都替代不了"
  },
];

class _PersionPageState extends State<PersionPage> {


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body:  Container(
          width: MediaQuery.of(context).size.width,
          height: 250.0,
          child: Swiper(
            itemBuilder: _swiperBuilder,
            itemCount: 7,
            pagination: new SwiperPagination(
              builder: DotSwiperPaginationBuilder(
                color: Colors.grey,
              )
            ),
            scrollDirection: Axis.horizontal,
            autoplay: true,

          )),

    );
  }
}

Widget _swiperBuilder(BuildContext context, int index) {
  return Container(
      child: Container(
        margin: EdgeInsets.only(top: 30),
        child: ListTile(
          leading: CircleAvatar(
            backgroundImage: NetworkImage(list[index]["url"]),
          ),
          title: Text(list[index]["text"]),
        ),
      ),
  );
}

